
def y(x):
    return x**2 +1 

def gcd(a,b):
    min_n = min(a,b)
    max_n = max(a,b)
    if min_n == 0 :
        return max_n

    if max_n % min_n == 0 :
        
        return min_n

    else :
        tem = max_n % min_n
        
        return gcd(min_n,tem)

def rho(n,x):
    g =  gcd(y(x)- x,n)
    if g > 1 and g< n:
        return g
    elif g == 1:
        return rho(n,y(x))
    else :
        return False

if __name__ == "__main__":
    a = long(raw_input("n > "))
    b = long(raw_input("start value x > "))
    
    print "rho : %ld | %ld " %(rho(a,b),a)
